package com.library.service.serviceImpl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.library.entity.Booktype;
import com.library.mapper.BookMapper;
import com.library.mapper.BooktypeMapper;
import com.library.service.IBooktypeService;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 至尊伍人组
 * @since 2018-09-30
 */
@Service
@Log
public class BooktypeServiceImpl extends ServiceImpl<BooktypeMapper, Booktype> implements IBooktypeService {
    @Autowired
    private BookMapper bookMapper;

    public List<Booktype> getAllBook( Wrapper<Booktype> wrapper ) {
        log.info("执行到了方法的开头");
        List<Booktype> list = super.selectList(wrapper);
        log.info("方法执行结束！");

        return list;
    }

    /**
     * 重写方法：根据图书种类的编号，删除指定类型图书
     * 同时删除该类图书下的所有图书
     *
     * @param id
     * @return
     */
    @Override
    @Transactional
    public boolean deleteById( Serializable id ) {

        //        bookMapper.delete(new EntityWrapper<Book>().eq("typeId", id));

        //        super.deleteById(id);

        return super.deleteById(id);
    }
}
